//
//  YCMeHomeMsgContentView.m
//  YCSchool
//
//  Created by gmall on 16/5/9.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//

#import "YCMeHomeMsgContentView.h"

@interface YCMeHomeMsgContentView()

/** 日期  */
@property (nonatomic, strong) UILabel *dateLabel;
/** icon  */
@property (nonatomic, strong) UIImageView *iconImageView;
/** 内容  */
@property (nonatomic, strong) UILabel *contentLabel;

/** block  */
@property (nonatomic, copy) contentViewClickBlock block;

@end


@implementation YCMeHomeMsgContentView


- (instancetype)initWithFrame:(CGRect)frame contentViewClickBlock:(contentViewClickBlock)block
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self makeView];
        self.backgroundColor = [UIColor yc_colorWithUInt:0x0 alpha:0.4];
        _block = block;
    }
    return self;
}


//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//        [self makeView];
//        self.backgroundColor = [UIColor yc_colorWithUInt:0x0 alpha:0.4];
//    }
//    return self;
//}

- (void)makeView
{
    UILabel *dateLabel = [[UILabel alloc] init];
    dateLabel.text = @"4/18";
    dateLabel.font = [UIFont boldSystemFontOfSize:17];//加粗
    dateLabel.textColor = [UIColor yc_colorWithUInt:0xffffff];
    [self addSubview:dateLabel];
    self.dateLabel = dateLabel;

    UIImageView *iconImageView = [[UIImageView alloc] init];
    iconImageView.contentMode = UIViewContentModeScaleAspectFill;
    iconImageView.image = [UIImage imageNamed:@"VIP班"];
    [self addSubview:iconImageView];
    self.iconImageView = iconImageView;
    
    UILabel *contentLabel = [[UILabel alloc] init];
    contentLabel.text = @"学车的第一天,整个人像打了鸡血一样的兴奋!";
    contentLabel.font = [UIFont systemFontOfSize:13];
    contentLabel.numberOfLines = 0;
    contentLabel.textColor = [UIColor yc_colorWithUInt:0xffffff];
    [self addSubview:contentLabel];
    self.contentLabel = contentLabel;

    [iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(90);
        make.width.height.equalTo(@64);
    }];
    
    [dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(iconImageView).offset(2);
        make.left.equalTo(self).offset(18);
    }];
    
    [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(dateLabel);
        make.left.equalTo(iconImageView.mas_right).offset(15);
        make.right.equalTo(self).offset(-15);
    }];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    !_block?:_block();
}

@end
